package everyday.leetcode;

/**
 * @Author: wenjingyuan
 * @Date: 2022/10/13/19:36
 * @Description:769. 最多能完成排序的块
 * https://leetcode.cn/problems/max-chunks-to-make-sorted/
 */
public class Num769 {
    public int maxChunksToSorted(int[] arr) {
        int ans=0;
        int ms=0;
        for (int i = 0; i < arr.length; i++) {
          ms=Math.max(ms,arr[i]);
          if(i==ms){
              ans++;
          }
        }
        return ans;
    }
}
